package com.blds.mc.interceptor;

import cn.binarywang.wx.miniapp.api.WxMaService;
import com.blds.mc.common.ConstCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.AsyncHandlerInterceptor;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * <p>
 * 微信小程序登陆拦截器
 * </p>
 *
 * @author stwyj
 * @since 2018/6/10
 */
@Component
@Slf4j
public class WxMAInterceptor implements HandlerInterceptor {
/*
    @Resource
    private WxMaService wxMaService;

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        HttpSession httpSession = request.getSession();

        String sessionOpenId = httpSession.getAttribute(ConstCode.SESSION_KEY_WX_MA_OPENID) == null ? null : String.valueOf(httpSession.getAttribute(ConstCode.SESSION_KEY_WX_MA_OPENID));

        if(StringUtils.hasText(sessionOpenId)) {
            return true;
        }

        return false;
    }*/
}
